<form id="CompetitionForm" class="layui-form layui-box modal-form-box" action="{:request()->url()}" data-auto="true" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">标 题</label>
        <div class="layui-input-block">
            <input autofocus name="title" value='{$vo.title|default=""}' required title="请输入标题" placeholder="请输入标题" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">
            图标
        </label>
        <div class='layui-input-block'>
            <img data-tips-image style="height:auto;max-height:320px;min-width:320px" src='{$vo.local_url|default=""}'/>
            <input type="hidden" name="local_url" onchange="$(this).prev('img').attr('src', this.value)" value='{$vo.local_url|default=""}' class="layui-input">
            <a class="btn btn-link" data-file="one" data-uptype="local" data-type="png,jpg,jpeg" data-field="local_url">上传图片</a>
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label">
            图文内容
        </label>
        <div class="layui-input-block">
            <textarea name='content'></textarea>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>

<textarea class="hide" id="content">{$vo.content|default=''|raw}</textarea>

<script>
    require(['ckeditor'], function () {
        var editor;
        var editDdata = document.getElementById('content').innerHTML;
        editor = window.createEditor('[name="content"]');
        editor.setData(htmldecode(editDdata));

        //html反转义输出
        function htmldecode(string) {
            var div = document.createElement('div');
            div.innerHTML = string;
            return div.innerText || div.textContent;
        }
    });
</script>